package managedbean; 
 
import entity.SaleLead; 
import java.io.IOException;
import java.util.List; 
import javax.ejb.EJB; 
import javax.faces.bean.ManagedBean; 
import javax.faces.bean.ViewScoped; 
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import session.stateless.SaleLeadBeanLocal; 
 
@ManagedBean(name="saleLeadDataTableBean")
@ViewScoped 
public class SaleLeadDataTableBean { 
    @EJB 
    private SaleLeadBeanLocal saleLeadBeanLocal; 
 
    public SaleLeadDataTableBean() { 
    } 
 
 
    public List<SaleLead> getSaleLeads() 
    { 
        return saleLeadBeanLocal.getSalesLead(); 
    } 
    
    
    public void editSaleLead(ActionEvent event) throws IOException
    {
        SaleLead selectedSaleLead = (SaleLead)event.getComponent().getAttributes().get("selectedSaleLead");    
        FacesContext.getCurrentInstance().getExternalContext().getFlash().put("selectedSaleLead", selectedSaleLead);
        FacesContext.getCurrentInstance().getExternalContext().redirect("editSaleLead.xhtml");                
    }
    
    public void deleteSaleLead(ActionEvent event) throws IOException
    {
        SaleLead selectedSaleLead =(SaleLead)event.getComponent().getAttributes().get("selectedSaleLead");
        FacesContext.getCurrentInstance().getExternalContext().getFlash().put("selectedSaleLead", selectedSaleLead);
        FacesContext.getCurrentInstance().getExternalContext().redirect("deleteSaleLead.xhtml");
    }
} 